package car.aistar.controller.loadjsp;

import car.aistar.controller.CarDetailController;
import car.aistar.dto.TqxCarSelect;
import io.swagger.models.auth.In;
import org.apache.catalina.connector.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 本类用来：
 *
 * @ClassName IndexJsp
 * @Author tqx
 * @Date 2020/10/12 14:15
 */
@Controller
@RequestMapping("/IndexJsp")
public class IndexJsp {

    @Autowired
    private CarDetailController carDetailController;

/**
*本方法用来:分页·{pageNow}/{pageSize}/{Nums}
*
*@param
*@return
**/
//IndexJsp/toIndex
@RequestMapping("/toIndex")
private String tt(Model model,TqxCarSelect tqxCarSelect){
    model.addAttribute("tqxCarSelect",tqxCarSelect);
    return "index/index02";
}


@RequestMapping("/toPage/{pageNow}/{pageSize}/{Nums}")
public String t(Model model , @PathVariable("pageNow") Integer pageNow, @PathVariable("pageSize") Integer pageSize, @PathVariable("Nums") Integer Nums){
    Integer pageNums = (int) Math.ceil(Nums*1.0/pageSize);
    model.addAttribute("pageNums",pageNums);
    model.addAttribute("pageSize",pageSize);
    model.addAttribute("Nums",Nums);
    return "page/indexCarpage02";

}
    /**
    *本方法用来:首页搜索框1 {likeStr}/{pageNow}/{pageSize}
    *
    *@param
    *@return
    **/
//    @PathVariable("likeStr") String likeStr,@PathVariable("pageNow")Integer pageNow,@PathVariable("pageSize")Integer pageSize
    @RequestMapping("/search1/{likeStr}/{pageNow}/{pageSize}")
    public  String t2(Model model,TqxCarSelect tqxCarSelect){
        System.err.println("*******==========="+tqxCarSelect);
        model.addAttribute("TqxCarSelect",tqxCarSelect);
        return  carDetailController.selectOne4(model,tqxCarSelect);
    }

    /**
     *本方法用来:首页搜索框2 {likeStr}/{pageNow}/{pageSize}
     *
     *@param
     *@return
     **/
//    @PathVariable("pageNow")Integer pageNow,@PathVariable("pageSize")Integer pageSize
    @RequestMapping("/search2/{pageNow}/{pageSize}")
    public  String t3(Model model,TqxCarSelect tqxCarSelect){
        System.err.println("search2==========="+tqxCarSelect);
        model.addAttribute("tqxCarSelect",tqxCarSelect);
        return  carDetailController.selectOne4(model,tqxCarSelect);
//        return "buyCar/buyCar02";
    }

    /**
    *本方法用来:首页--价格{price}
    *
    *@param
    *@return
    **/
//    @PathVariable("price")Integer price
    @RequestMapping("/price/{price}")
    public  String t4(Model model,TqxCarSelect tqxCarSelect){
        model.addAttribute("tqxCarSelect",tqxCarSelect);
        return  carDetailController.selectOne4(model,tqxCarSelect);
//        return "buyCar/buyCar02";
    }

    /**
    *本方法用来:brId+brName
    *
    *@param
    *@return
    **/
//    @PathVariable("brId")Long brId,@PathVariable("brName")String brName
    @RequestMapping("/search3/{brId}/{brName}")
    public  String t5(Model model, TqxCarSelect tqxCarSelect){
        System.err.println("search3==========="+tqxCarSelect);
        model.addAttribute("tqxCarSelect",tqxCarSelect);
        return  carDetailController.selectOne4(model,tqxCarSelect);
    }

/**
*本方法用来:{brId}/{csId}/{csName}
*
*@param
*@return
**/
//@PathVariable("brId")Integer brId,@PathVariable("csId") Integer csId ,@PathVariable("csName")String brName
    @RequestMapping("/search4/{brId}/{csId}/{csName}")
    public  String t6(Model model,TqxCarSelect tqxCarSelect){
        System.err.println("search4==========="+tqxCarSelect);
        model.addAttribute("tqxCarSelect",tqxCarSelect);
        return  carDetailController.selectOne4(model,tqxCarSelect);
//        return "buyCar/buyCar02";
    }


}
